
import { cloneDeep } from 'lodash'
export default {
  namespaced: true,
  state: {
    // 路由记录
    history: []
  },
  actions: {
    pushHistory ({ state }, payload) {
      if (!/\/.+\/.+/.test(payload.path)||/login/.test(payload.path)) return
      if (!state.history.find(item => item.path === payload.path)) {
        state.history.push(payload)
      }
    },
    removeHistoryByPath ({ state }, path) {
      const index = state.history.findIndex(item => item.path === path)
      state.history.splice(index, 1)
    },
    getHistoryCopy ({ state }) {
      return cloneDeep(state.history)
    }
  }
}
